<!-- 商品列表页面 -->
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="gbk">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>apple手作</title>
    <link href="/static/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
    <script src="/static/js/bootstrap.bundle.min.js"></script>
    <style>
      .modal-dialog {
        margin: 200px auto !important;
      }
      a {
        text-decoration: none;
      }
      a:hover {
        color: aliceblue;
      }
    </style>
</head>
<body>
    <!-- 头部 -->
    <header onClick="toHome()">
        <div class="navbar navbar-dark bg-dark shadow-sm">
          <div class="container">
            <a href="#" class="navbar-brand d-flex align-items-center">
              <strong>apple手作</strong>
            </a>
          </div>
        </div>
      </header>
      <!-- 主体部分 -->
      <main>
        <!-- 按钮 -->
        <section class="py-5 text-center container">
            <div class="row py-lg-5">
              <div class="col-lg-6 col-md-8 mx-auto">
                <p>
                  <a href="#" class="btn btn-primary my-2" data-bs-toggle="modal" data-bs-target="#exampleModal">输入金额</a>
                  <a href="/cart" class="btn btn-secondary my-2">购物车</a>
                  {% if total_money !=None and total_money > 0 %}
                    <div>
                      <span class="money-num">账户当前金额：￥{{ total_money }}</span>
                    </div>
                  {% endif %}
                </p>
              </div>
            </div>
        </section>
        <!-- 商品 -->
        <div class="album py-5 bg-light">
            <div class="container">
              <div class="row row-cols-1 row-cols-sm-2 row-cols-md-3 g-3">
                {% for i in goods_list %}
                  <div class="col">
                      <div class="card shadow-sm">
                        <img src="{{ i['img'] }}" class="bd-placeholder-img card-img-top" width="100%" height="300">
                        <div class="card-body">
                          <p class="card-text">{{ i['name'] }}</p>
                          <div class="d-flex justify-content-between align-items-center">
                            <div class="btn-group">
                              <button type="button" class="btn btn-sm btn-outline-secondary">
                                <a href="/cart?_id={{ i._id }}">加入购物车</a>
                              </button>
                              <button type="button" class="btn btn-sm btn-outline-secondary">
                                <a href="/buy?_id={{ i._id }}">购买</a>
                              </button>
                            </div>
                            <small class="text-muted">￥{{ i['price'] }}</small>
                          </div>
                        </div>
                      </div>
                    </div>
                    {% endfor %}
                  </div>
            </div>
        </div>
        <!-- 弹窗：用于输入金额，金额会存入session -->
        <div class="modal fade" id="exampleModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
          <div class="modal-dialog">
            <div class="modal-content">
              <div class="modal-header">
                <h5 class="modal-title" id="exampleModalLabel">输入金额</h5>
                <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
              </div>
              <div class="modal-body">
                <form action="/submit/money" method="GET">
                  <input type="text" class="form-control" name="money" style="width:180px;float:left">
                  <input type="submit" class="btn btn-primary" style="float:left;margin-left:20px;">
                </form>
              </div>
            </div>
          </div>
        </div>
      </main>
      <script>
        // 回到首页
        function toHome(){
          window.location.href = '/'
        }
      </script>
</body>
</html>